package cn.falcon.fmobi.console.requestparam;

import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class AccountQuery extends AbstractPagingSortParam {
	/**
	 * 搜索关键词， 名称或者ID
	 */
	private String search;

	public String getSearch() {
		return search;
	}

	public void setSearch(String search) {
		this.search = search;
	}

	/**
	 * 默认按id排序
	 */
	@Override
	public String getSortby() {
		return StringUtils.isEmpty(super.getSortby()) ? "id" : super.getSortby();
	}

	/**
	 * 默认按降序排序
	 */
	@Override
	public ORDER getOrder() {
		return super.getOrder() == null ? ORDER.desc : super.getOrder();
	}

	public Map<String,Object> getSearchMap(){
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("search", this.search);
		map.put("offset", this.getOffset());
		map.put("limit", this.getLimit());
		return map;
	}

}
